$(document).ready(function(){
    var $token = window.localStorage.getItem("token");
    var $mid= window.localStorage.getItem("mid");


    var $groupid= window.localStorage.getItem("groupId");
    var Post ="mid="+$mid+"&groupid="+$groupid+"&pagesize=10&token="+$token+"&did=66666";
	$.ajax({
		url:'../../api/group/getgroupbusinessinfolist',
		type:'post',
		data:Post,
		success:function(msg){
			if(msg.code ==100){
				console.log(msg);
				var $div = document.getElementById("banner_list");
				var $ul= document.getElementById("banner_ctrl");
				var $ul0 = document.getElementById("content_list");
				for (var i = 0; i < msg.datum.n0.length; i++) {
						var $a = document.createElement("a");
						var $li = document.createElement("li");
						$a.href="busiOppDtailes.html?bid="+msg.datum.n0[i].n0;
						$a.innerHTML = '<img src="'+msg.datum.n0[i].n1.split(",")[0]+'" title="小清新" alt="小清新"/>';
						$div.appendChild($a,$div.childNodes[0]);
						$ul.appendChild($li,$ul.childNodes[0]);
				}	
				$ul.firstChild.class='on';
				circule();
				for (var j = 0; j < msg.datum.n1.length; j++) {
					var $li0 = document.createElement("li");
					
					$li0.innerHTML='<a href="busiOppDtailes.html?bid='+
					msg.datum.n1[j].n0+'">'+'<div class="busiOppListLeft">'+
	                    '<img src="'+
						msg.datum.n1[j].n1.split(",")[0]+'"/>'+
	                '</div>'+
	                '<div class="busiOppListRight">'+
	                    '<h4>'+msg.datum.n1[j].n2+'</h4>'+
	                    '<p class="name">'+msg.datum.n1[j].n4+'</p>'+
	                    '<p class="post">'+msg.datum.n1[j].n5+'<button>'+msg.datum.n1[j].n6+'</button></p>'+
	                    '<p class="">'+
	                        '<img style="width:20px;height:20px;" src="../../source/images/icon/busiOppCollect.png"><span>'+msg.datum.n1[j].n7+'</span>'+
	                        '<img style="width:20px;height:20px;" src="../../source/images/icon/busiOppComment.png"><span>'+msg.datum.n1[j].n8+'</span>'+
	                        '<img style="width:20px;height:20px;" src="../../source/images/icon/busiOppDate.png"><span>'+msg.datum.n1[j].n9+'</span>'+
	                    '</p>'+
	                '</div></a>';
					
					/*$li0.innerHTML = '<a href="sub_dem_list.html?bid='+
					msg.datum.n1[j].n0+'"><div class="logo"><img src="'+
					msg.datum.n1[j].n1.split(",")[0]+'"/></div><div class="dymanic"><span class="title">'+
					msg.datum.n1[j].n2+'</span><span class="time">'+
					msg.datum.n1[j].n3+'</span><span class="include">'+
					msg.datum.n1[j].n4+'</span><span class="comment">'+
					msg.datum.n1[j].n8+'</span></div></a>';*/
					
					$ul0.appendChild($li0,$ul0.childNodes[0]);
				}
			}
		}
	});
});

var t= n = 0,count;
function circule() {
    count = $("#banner_list a").length;
    $("#banner_list a:not(:first-child)").hide();
    $("#banner>ul>li").click(function(){
        var i = $(this).index();
        n = i;
        if(i>=count) return;
        $("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(500);
        document.getElementById("banner").style.background ="";
        $(this).toggleClass("on");
        $(this).siblings().removeAttr("class");
    });
    t = setInterval("showAuto()",4000);
    $("#banner").hover(function(){
        clearInterval(t);
    },function(){
        t = setInterval("showAuto()",4000);
    });
};
function showAuto() {
    n = n >= (count - 1) ? 0 : ++n;
    $("#banner>ul>li").eq(n).trigger("click");
}
function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]); return null;
}